while read LINE do echo "begin to restore file " $LINE ext3grep /dev/vgdata/LogVol00 --restore-file $LINE if [ $? != 0 ] then echo "restore failed, exit" # exit 1 fi done < ./mysqltbname.txt
sys@GLOBAL>col NAME for a100; sys@GLOBAL>select FILE#,NAME from v$datafile; FILE# NAME ---------- ---------------------------------------------------------------------------------------------------- 1 /home/oracle/app/oradata/global/system01.dbf 2 /home/oracle/app/oradata/global/sysaux01.dbf 3 /home/oracle/app/oradata/global/undotbs01.dbf 4 /home/oracle/app/oradata/global/users01.dbf 5 /home/oracle/app/oradata/global/GLOBAL_ORDER01.dbf 6 /home/oracle/app/oradata/global/TS_DCIS_WMS01.dbf 7 /home/oracle/app/oradata/global/TS_DCIS_WMS02.dbf 7 rows selected. sys@GLOBAL>!rm -f /home/oracle/app/oradata/global/* sys@GLOBAL>create table t tablespace users as select * from dual; create table t tablespace users as select * from dual * ERROR at line 1: ORA-01116: error in opening database file 4 ORA-01110: data file 4: '/home/oracle/app/oradata/global/users01.dbf' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3
SQL*Plus: Release 11.2.0.4.0 Production on Wed Dec 7 03:47:39 2016
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Oracle Label Security, OLAP, Data Mining and Real Application Testing options
sys@GLOBAL>create table t tablespace users as select * from dual;
Table created.
完成数据文件恢复。
6.如果数据库不可用,可能还会涉及到数据文件等的恢复过程,使用以下命令恢复数据文件:
1 2 3
alter database datafile 1 offline; recover datafile 1; alter database datafile 1 online;
恢复的原理:在 Linux 操作系统中,如果文件从操作系统级别被rm掉,之前打开该文件的进程仍然持有相应的文件句柄,所指向的文件仍然可以读写,并且该文件的文件描述符可以从 /proc 目录中获得。但是要注意的是,此时如果关闭数据库,则此句柄会消失,那么除了扫描磁盘进行文件恢复之外就没有其它方法了,因此在数据库出现问题的时候,如果不确认情况的复杂程度,千万不要随便关闭数据库。重启数据库往往是没有意义的,甚至是致命的。